package com.jzk.cloudshop.eurekaclienttemplate.web;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api("demo例子")
@RestController
class HelloController {
	
	protected static final Logger logger = LoggerFactory.getLogger(HelloController.class);

    @Value("${myconf.hello}")
    private String hello;
    
	@Autowired
	DiscoveryClient discoveryClient;

	@ApiOperation(value="获取service列表", notes="")
	@GetMapping(value={"/service-list"})
	public String dc() {
		String services = "Services: " + discoveryClient.getServices();
		logger.info(services);
		return services;
	}
	
	@ApiOperation(value="欢迎信息，测试配置中心读取git配置", notes="")
    @RequestMapping(value={"/hello"}, method=RequestMethod.GET)
    public String hello() {
        return this.hello;
    }
}